<?php
include_once("../metier/proposition.dao.php");
include_once("../metier/proposition.class.php");
include_once("../metier/reponse.dao.php");
include_once("../metier/reponse.class.php");
include_once("../metier/myPDO.class.php");

header("Content-Type: text/plain");

$idQ = (isset($_GET["idQuestion"])) ? $_GET["idQuestion"] : NULL;
$libReponse = (isset($_GET["libRep"])) ? $_GET["libRep"] : NULL;
 
if ($idQ) {
	$db = new myPDO("127.0.0.1", "root", "", 0);
	
	$propositionDAO = new PropositionDAO();
	$reponseDAO = new ReponseDAO();
	
	$reponse = new Reponse(0, $libReponse);
	$reponseDAO->createReponse($reponse, $db);
	$idR = $db->lastInsertId();
	$proposition = new Proposition($idQ, $idR);
	
	$propositionDAO->createProposition($proposition, $db);
	print_r($proposition);
} else {
    echo "FAIL";
}
 
?>